<template>
  <view class="home_category">
    <navigator class="cate_item"  v-for="item in category" 
    :key="item.id" :url="`/pages/imgCategory/index?id=${item.id}`">
      <image :src="item.cover" mode="aspectFill">
      <view class="cate_name">{{item.name}}</view>
    </navigator>
  </view>
</template>

<script>
export default {
  data(){
    return {
      category:[]
    }
  },
  methods:{
    getList(){
      this.request({
        url:"http://157.122.54.189:9088/image/v1/vertical/category"
      })
      .then(res=>{
        this.category = res.res.category;
      })
    }
  },

  mounted(){
    this.getList();
  }

}
</script>

<style lang="scss" scoped>
.home_category{
  display: flex;
  flex-wrap: wrap;
  .cate_item{
    position: relative;
    width: 33.33%;
    border: 5rpx #fff solid;
    image{
      height: 240rpx;
    }
    .cate_name{
      padding-left: 20rpx;
      display: flex;
      position: absolute;
      left: 0;
      bottom: 0;
      align-self: center;
      font-size: 30rpx;
      height: 40rpx;
      width: 100%;
      color: #fff;
      //渐变
      background-image: linear-gradient(to right top,rgba(0,0,0,0.2),rgba(0,0,0,0));
    }
  }
}
</style>